b864e71660686246932c4d857b48fb7ac9ace3e5,Code/JavaSrc/edu/biu/scapi/midLayer/asymmetricCrypto/encryption/ScDamgardJurikEnc.java,ScDamgardJurikEnc,reRandomize,#AsymmetricCiphertext#,390
Before Change
BigIntegerCiphertext djCipher = (BigIntegerCiphertext) cipher;
//n is the modulus in the public key.
//Calculates s = (|cipher| -1) / |n|.
int s = ((djCipher).getCipher().bitLength() - 1) / publicKey.getModulus().bitLength();
//Calculates N and N' based on s: N = n^s, N' = n^(s+1).
BigInteger n = publicKey.getModulus();
BigInteger N = n.pow(s);
BigInteger Ntag = n.pow(s+1);
//Makes sure the cipher belongs to ZN'.
if(djCipher.getCipher().compareTo(BigInteger.ZERO) < 0 || djCipher.getCipher().compareTo(Ntag) >= 0)
throw new IllegalArgumentException("The cipher is not in ZN'");
BigInteger NtagMinus1 = Ntag.subtract(BigInteger.ONE);
//Chooses a random r in ZNtag*, this can be done by choosing a random value between 1 and Ntag -1
//which is with overwhelming probability in Zntag*.
BigInteger r = BigIntegers.createRandomInRange(BigInteger.ONE, NtagMinus1, random);
BigInteger c = djCipher.getCipher().multiply(r.modPow(N, Ntag));
return new BigIntegerCiphertext(c);
}
/**
After Change
BigIntegerCiphertext djCipher = (BigIntegerCiphertext) cipher;
//n is the modulus in the public key.
//Calculates s = |cipher| / |n|.
int s = (djCipher).getCipher().bitLength() / publicKey.getModulus().bitLength();
//Calculates N and N' based on s: N = n^s, N' = n^(s+1).
BigInteger n = publicKey.getModulus();
BigInteger Ntag = n.pow(s+1);
BigInteger NtagMinus1 = Ntag.subtract(BigInteger.ONE);
//Chooses a random r in ZNtag*, this can be done by choosing a random value between 1 and Ntag -1
//which is with overwhelming probability in Zntag*.
BigInteger r = BigIntegers.createRandomInRange(BigInteger.ONE, NtagMinus1, random);
return reRandomize(cipher, r);
}
/**